// 鍏ㄥ眬鍙橀噺
// 椤甸潰瀹介珮
var _win_h = _win_w = 0;
// 婊氬姩鏉″搴�
var _scroll_width = 0;
// 杞挱
var bodyClick = new AllAreaFun();
// 妯″潡鍔犺浇瀹�
var divLoadFun = new AllAreaFun();
// 椤甸潰婊氬姩
var winScroll = new AllAreaFun();
winScroll.active = true;
winScroll.timerOut = null;
winScroll.srctop = $(window).scrollTop();
// 绐楀彛鍙樺姩
var winSize = new AllAreaFun();
winSize.timeOut = true;
// 闅忔満鏁�
var _Mathnum = new randomNum(9999, 99999999);
// 婊氬姩璺濈
var _scrollTop = $(window).scrollTop();
// 鍒ゆ柇褰撳墠椤甸潰鏄惁鏄痠frame
var _isFrame = null;
_isFrame = window.frameElement;

// svg鏇挎崲
var svgJs;

// 鍏ㄥ眬鏂规硶
winSize.addFun('a',function(){
	// 鑾峰彇娴忚鍣ㄦ粴鍔ㄦ潯瀹藉害
	_scroll_width = getScrollbarWidth();
	document.querySelector('html').style.setProperty('--scroll-w', _scroll_width + 'px');

	// 璁剧疆绐楀彛澶у皬
	setWind();
});

// 鑾峰彇绐楀彛楂樺害瀹藉害
function setWind(){
	_win_h = $(window).height();
	_win_w = $(window).width()+_scroll_width;
}


// js鍔犺浇妯″潡
var _lwdiv_num = document.getElementsByTagName('lwdiv').length;

// DOM 鍔犺浇瀹屾瘯
document.onready = function () {
	_lwdiv_num = document.getElementsByTagName('lwdiv').length;
	start_load_document();

	let _local = window.location.hostname
	if(_local == '192.168.1.189'){
		console.log(`鏈湴鍩熷悕锛�${_local}`)
		$('link').each(function(){
			var _href = $(this).attr('href')+'?vTime=' + new Date().getTime();
			$(this).attr('href',_href);
		});
	}
}

// 鎵ц妯″潡鍔犺浇
function start_load_document() {
	var jsArray = [];
	var jsDom = document.querySelector('block[name="script-part"]');
	if (_lwdiv_num != 0) {
		$('lwdiv').each(function () {
			var _this = $(this),
				_arr = _this[0].attributes, //鑾峰彇灞炴€�
				file_dir = '', //鏂囦欢璺緞
				_attrObj = {}, //杞寲鍚庣殑灞炴€�
				regEx,
				jsReg =  /<block name="script-son">(([\s\S])*?)<\/block>/g,
				_html = '';
			for (var i = 0; i < _arr.length; i++) {
				_attrObj[_arr[i].name.replace('lw-', '')] = _arr[i].value;
			}
			file_dir = _attrObj.file;
			if (!file_dir) {
				console.error('璇峰～鍐欐枃浠惰矾寰勫搰锛�--------鎻愮ず')
				return false;
			}
			// 鍦板潃鍔犳椂闂存埑闃叉缂撳瓨
			file_dir = file_dir + '?vTime=' + new Date().getTime();
			$.ajax({
				url: file_dir,
				type: 'GET',
				success: function (e) {
					var _html = '',
						_obj,
						jsResultArr = [];

					// 鎷縥s浠ｇ爜
					jsResultArr = jsReg.exec(e);
					if(jsResultArr){
						jsArray.push(jsResultArr[1]);
					}
					// 鍘绘帀js浠ｇ爜
					e = e.replace(jsReg, '');

					for (var k in _attrObj) {
						regEx = new RegExp('{\\s*' + k + '\\s*}', 'g');
						e = e.replace(regEx, _attrObj[k]);

						// e = e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"");
						// e = e.replace(/<!-- Code injected by live-server -->/gi,"");
					}
					_this.before(e);
					_obj = _this.prev();
					for (var k in _attrObj) {
						_obj.find('*[lw-' + k + ']').attr(k, _attrObj[k]).removeAttr('lw-' + k);
					}
					// 鍐欏叆 html缁撴瀯
					_html = _obj.html();
					// _html = _html.replace('lw-', '');
					_html = _obj.html(_html);
					_this.remove();
					// 鍐欏叆 js
					_lwdiv_num--;
					if (_lwdiv_num == 0) {
						// console.log(jsDom)
						// jsDom.innerHTML = jsArray[0];
						fun_load();
					}
				}
			})
		});
	} else {
		fun_load();
	}
}

function fun_load() {

	// 鍏ㄥ眬娣诲姞Body鐐瑰嚮浜嬩欢
	$('body').click(function(e){
		bodyClick.eventClick = e;
		bodyClick.runFun();
	});

	//鍔犺浇鍚庢墽琛�
	divLoadFun.runFun();

	// 椤甸潰鍙樺寲
	winSize.runFun();

	// 婊氬姩
	winScroll.srctop = $(window).scrollTop();
	if(winScroll.srctop > 0){
		winScroll.runFun();
	}

	/***杞挱***/
	var _swiper_arr = document.querySelectorAll('.swiper');
	var _swiper_item = 0;
	for(var k of _swiper_arr){
		var _this = k;
		var _attr = _this.attributes;
		var _can_swiper = true;
		if(_attr['data-auto-swiper']){
			_can_swiper = _attr['data-auto-swiper'].value=='false'?false:true;
		}
		var _class = _attr['data-swiper-class']?_attr['data-swiper-class'].value:'swiper_'+_swiper_item;
		var _json = _attr['data-swiper-json']?_attr['data-swiper-json'].value:false;
		if(_can_swiper && _json){
			// 瀛楃涓茶浆json
			_json = eval('('+_json+')');
			window[_class] = new Swiper(_this,_json)
		}
		_swiper_item = _swiper_item + 1;
	}

	/***鍙粴鍔ㄨ彍鍗�***/
	if ($('.next-menu .swiper-slide').length > 0) {
		var _next_menu_index = $('.next-menu .link').index($('.next-menu .on'));
		_next_menu_index = _next_menu_index>=0?_next_menu_index:0;
		setTimeout(function(){
			var _next_menu = new Swiper('.next-menu .swiper', {
				watchOverflow: true,//鍥犱负浠呮湁1涓猻lide锛宻wiper鏃犳晥
				slidesPerView: 'auto',
				// simulateTouch: false,
				initialSlide: _next_menu_index,
				centerInsufficientSlides: true
			})
		},100);
	}

	// svg鍥炬爣
	try {
		if(SvgIcon){
			svgJs = new SvgIcon();
		}
	} catch (error) {

	}

	/**鍒囨崲閫夐」鍗�**/
	var TablesCheck1 = TablesCheck($('.tab-box'), function () { });

	// 浜岀骇鑿滃崟閿氱偣
	var _goScrollLink = hrefGetParameter('link');
	if (_goScrollLink && typeof _goScrollLink.link !== 'undefined') {
		setTimeout(function () {
			goScrollFun('link=' + _goScrollLink.link);
		}, 100);
	}

	// 璇曠敤椤甸潰
	if($('.index-apply').length){
		$('body').addClass('has-index-apply');
	}

	// 鍒嗙被绛涢€変笅鎷�
	screeningFun();

	// 閫氱敤涓嬫媺妗�
	addSelectElement();

	// 寮规
	$(document).on('click','.tank-block-switch',function(){
		var _class = $(this).attr('data-point');
		$('.'+_class).fadeIn();
	});
	$(document).on('click','.tank-block .exit',function(){
		$(this).parents('.tank-block').fadeOut();
	});

	// 鍥剧墖涓婁紶
	$(".upload-img-block").each(function(){
		uplpadPic( $(this).find(".upload-input"),$(this).find("img") );
	});
	$(".upload-img-block").each(function(){
		uplpadPicDelete( $(this).find(".delete"),$(this).find("img") );
	});

	//鍒嗕韩
	$('*[data-share="share-box"]').each(function (i) {
		var _this = $(this);
		var _url = window.location.href;
		var _des = $('meta[name="description"]').attr('content');
		var _title = $('title').text();
		_this.find('.sina').attr('href', 'http://service.weibo.com/share/share.php?title=' + _title + '&url=' + _url);
		_this.find('.qq').attr('href', 'http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=' + _url + '&title=' + _title + '&desc=' + _des);
		if (_this.find(".creat-code-box").length > 0) {
			new QRCode(_this.find(".creat-code-box")[0], _url);
		}
	});
	//鎺у埗澶撮儴骞垮憡
	$(".closed").click(function(){
		$(".header_adv").css("height",0);
	})

}

// 娴忚鍣ㄩ〉闈㈠彉鍖�
$(window).resize(function () {
	clearTimeout(winSize.timeOut);
	winSize.timeOut = setTimeout(function(){
		winSize.runFun();
	},100);
})

var _scrollTopAll = 0;
// 婊氬姩鏃剁殑闂撮殧
$(window).scroll(function (e) {
	scrollFun();
});

scrollFun();
// 婊氬姩鏂规硶
function scrollFun(){
	var srctop = $(window).scrollTop();
	// 澶撮儴
	var _delta = srctop > _scrollTopAll ? 1 : -1; // chrome & ie || firefox
	_scrollTopAll = srctop;
	if (srctop > $('.header-box-space').height()) {
		$('body').addClass('small-header');
		if (_delta > 0) {
			// 鍚戜笂婊�
			$('body').removeClass('show-header');
		} else if (_delta < 0) {
			// 鍚戜笅婊�
			$('body').addClass('show-header');
		}
	} else {
		$('body').removeClass('show-header');
		$('body').removeClass('small-header');
	}

	if(_scrollTopAll > _win_h){
		$('body').addClass('show-fix');
	}else{
		$('body').removeClass('show-fix');
	}

	_scrollTop = srctop;
	winScroll.srctop = srctop;
	clearTimeout(winScroll.timerOut);
	winScroll.timerOut = setTimeout(function () {
		winScroll.runFun();
	}, 100);
}

// 鍒嗙被绛涢€変笅鎷�
function screeningFun(){
	var _this = this;
	_this.init = function(){
		$('.screening-block .dl .dd').each(function(){
			var _this2 = this;
			var _max = $(_this2).height();
			var _min = $(_this2).find('.ul li').eq(0)[0].offsetHeight;
			_this2.style.setProperty('--maxh',_max+'px')
			if(_max > _min*1.1){
				$(_this2).parent().addClass('has-btn');
				$(_this2).find('.ul .on').each(function(){
					var _this3 = this;
					if($(_this3)[0].offsetTop > _min*.6){
						$(_this2).parent().addClass('show-more');
					}
				});
			}else{
				// $(this).parent().removeClass('has-btn');
			}
		});
	}

	_this.init();
	window.onresize = function(){
		_this.init();
	}

	$('.screening-block .dl .screening-switch').click(function(){
		var _p = $(this).parents('.dl').eq(0);
		if(_p.hasClass('show-more')){
			_p.removeClass('show-more');
		}else{
			_p.addClass('show-more');
		}
	});
}

// 閫氱敤涓嬫媺妗嗚缃紙锛�
function addSelectElement(){
	if($('.select-self .select-word').length > 0){
		// 缁檅ody娣诲姞閫氱敤涓嬫媺妗嗘秷澶变簨浠�
		bodyClick.addFun('selectSelfHide',function(){
			if($('.select-self.show-list').length > 0){
				var _e = bodyClick.eventClick;
				if($(_e.target).parents('.select-self').length < 1){
					$('.select-self.show-list').removeClass('show-list');
				}
			}
		});
		$('.select-self').each(function(){
			var _this = $(this);
			if(_this.find('.select-list li[checked]').length > 0){
				var _text = _this.find('.select-list li[checked]').text();
				var _val = _this.find('.select-list li[checked]').attr('val');
				_this.find('.select-word').text(_text);
				_this.find('.select-val').val(_val);
				_this.find('.select-val').trigger("input");
				_this.find('.select-val').change();
			}
		});
		$(document).off('click','.select-self .select-word').on('click','.select-self .select-word',function(){
			var _this = $(this).parents('.select-self').eq(0);
			var _list = $('.select-self');
			var _inx = _list.index(_this);
			for(var i=0,len=_list.length;i<len;i++){
				if(i != _inx){
					$(_list[i]).removeClass('show-list');
				}else{
					$(_list[i]).toggleClass('show-list');
				}
			}
		});
		$(document).on('click','.select-self .select-list li',function(e){
			var _this = $(this);
			var _select = _this.parents('.select-self');
			var _val = _this.attr('val');
			var _text = _this.text();
			_select.find('.select-word').text(_text);
			_select.find('.select-val').val(_val);
			_select.find('.select-val').trigger("input");
			_select.find('.select-val').change();
			if(_val!='' && typeof(_val) != 'undefined'){
				_select.addClass('hasVal').removeClass('noVal');
				_this.attr('checked','');
			}else{
				_select.removeClass('hasVal').addClass('noVal');
			}
			_select.removeClass('show-list');
			_this.siblings().removeAttr('checked');
			_this.addClass('checked').siblings().removeClass('checked');
		});
	}
}

/**iframe寮规**/
$(document).on('click', '.iframe-btn', function () {
	var _href = $(this).attr('href');
	var _parameter = $(this).attr('data-parameter');
	var _id = 'Iframe_';
	for (var i = 0; i < 999999; i++) {
		if ($('#' + _id + i).length > 0) {
			continue;
		} else {
			_id = _id + i;
			break;
		}
	}
	if (_parameter != undefined) {
		if (_href.indexOf('?') < 0) {
			_href = _href + '?' + _parameter;
		} else {
			_href = _href + '&' + _parameter;
		}
	}
	$('body').append(`<iframe class="iframe-iframe loading" id="${_id}" src="${_href}?vTime=${new Date().getTime()}"></iframe>`);
	return false;
});

/**鍒犻櫎iframe寮规**/
function delteIframe(obj, callback) {
	callback(obj);
	$(obj).fadeOut();
}

/***
 * 寮瑰嚭寮忚〃鍗�
 */
$(document).on('click','.form-switch-btn',function(e){
	$(this).parents('.form-box').addClass('show-form');
});

/***绉诲姩绔彍鍗�***/
$(document).on('click', '.phone-menu', function () {
	if ($('body').hasClass('menu-show')) {
		$('body').removeClass('menu-show');
		$('.language-box').removeClass('show-list');
	} else {
		$('body').addClass('menu-show');
	}
});
/***绉诲姩绔ご閮ㄨ彍鍗曚笅鎷�***/
$(document).on('click', '.sub-icon', function () {
	if($(window).width() < 1200){
		var _obj = $(this).parents('.menu-son');
		if(_obj.find('.sub-block').length > 0){
			if (_obj.find('.menu-title').hasClass('on')) {
				_obj.find('.menu-title').removeClass('on');
				_obj.find('.sub-block').slideUp();
			} else {
				_obj.find('.menu-title').addClass('on');
				_obj.find('.sub-block').slideDown();
			}
			return false;
		}
	}
});
/***绉诲姩绔簳閮ㄨ彍鍗曚笅鎷�***/
$(document).on('click', '.menus .menus-li .jt', function () {
	if($(window).width() < 1200){
		var _obj = $(this).parents('.menus-li');
		if(_obj.find('.sub-block').length > 0){
			if (_obj.find('.menus-title').hasClass('on')) {
				_obj.find('.menus-title').removeClass('on');
				_obj.find('.sub-block').slideUp();
			} else {
				_obj.find('.menus-title').addClass('on');
				_obj.find('.sub-block').slideDown();
			}
			return false;
		}
	}
});
/***璇█鍒囨崲***/
$(document).on('click','.language-switch',function(){
	if($('.language-box').hasClass('show-list')){
		$('.language-box').removeClass('show-list');
	}else{
		$('.language-box').addClass('show-list');
	}
});


// 琛ㄥ崟椤甸潰
// 涓嬫媺
$(document).on('click','.algorithm-form-block .form .city-input',function(e){
	e.preventDefault();
});
// 楠岃瘉
$(document).on('blur','.algorithm-form-block .form .input',function(){
	checkInput(this);
});
$(document).on('input prototype','.algorithm-form-block .form .input',function(){
	checkInput(this);
});
// 瀛楁暟
$(document).on('input prototype','.input[data-calc-num]',function(){
	var _this = $(this);
	var _val = _this.val();
	var _p = _this.parent();
	var _num = _val.length;
	_p.find('.num-total-box .num-current').text(_num);
});
function checkInput(_o){
	var _this = $(_o);
	var _val = _this.val();
	var _p = _this.parents('.cont-box');
	var _verify = _this.attr('verify');
	var _json = evil(_this.attr('verify-json'));
	if(_this.attr('required') == 'required'){
		if(_val == ''){
			_p.addClass('has-error');
			_p.find('.error-tips').text(_json['empty']);
		}else{
			_p.removeClass('has-error');
		}
	}
	if(_verify == 'phone' && _val != ''){
		if(isPoneAvailable(_val)){
			_p.removeClass('has-error');
		}else{
			_p.addClass('has-error');
			_p.find('.error-tips').text(_json['error']);
		}
	}
}


// 澶撮儴鑿滃崟鏁堟灉
$(document).on('mouseenter','#header .menu-block .menu-son',function(){
	headMenuHover(this);
});
function headMenuHover(o){
	var _len = $(o)[0].offsetLeft;
	var _w = parseInt($(o).width()/2);
	_len = _len + _w;
	$('#header .menu-block .menu')[0].style.setProperty('--len',_len+'px');
}

// 搴曢儴鍙嬫儏閾炬帴
$(document).on('click','.friend-li-switch',function(){
	var _o = $(this).parents('.friend-link-box');
	if(_o.hasClass('show')){
		_o.removeClass('show');
	}else{
		_o.addClass('show');
	}
});

/**杩斿洖澶撮儴**/
$(document).on('click', '.return-top', function () {
	$('body,html').animate({ 'scrollTop': 0 }, 500);
});

// 浜岀骇鑿滃崟閿氱偣
$(document).on('click', '*[data-url]', function () {
	var _link = $(this).attr('data-url');
	if (_link) {
		goScrollFun(_link);
		return false;
	}
});
function goScrollFun(str) {
	var _str_arr = str.split('='),
		_link_str = '',
		_len = 0;
	if (_str_arr.length < 2) {
		return false;
	}
	_link_str = _str_arr[1];
	_len = $('.' + _link_str).offset().top - $('#header').height();
	// if($('.next-menu').length > 0){
	//   _len = _len - $('.next-menu').height();
	// }
	$('*[data-url]').removeClass('on');
	$('*[data-url="' + str + '"]').addClass('on');
	$('html,body').animate({ 'scrollTop': _len }, 500);
}

// 瑙嗛
$(document).on('click', '.video-play', function () {
	if($(this).parent('.video-play-box').find('video').length > 0){
		$(this).parent('.video-play-box').addClass('controls');
		$(this).parent('.video-play-box').find('video')[0].play();
		$(this).parent('.video-play-box').find('video').attr('controls','true');
		return false;
	}
	var src = $(this).attr('data-src') ? $(this).attr('data-src') : $(this).find('video').attr('src');
	if (src) {
		$('.tank-video-box').find('video').attr('src', src);
		$('.tank-video-box').fadeIn();
		$('.tank-video-box').find('video')[0].play();
		$('.tank-video-box').find('video').attr('controls',"");
		return false;
	}
});
$(document).on('click', '.tank-video-box', function () {
	$('.tank-video-box').fadeOut();
	$('.tank-video-box').find('video')[0].pause();
});
$(document).on('click', '.tank-video-box video', function (e) {
	e.preventDefault();
	e.stopPropagation();
});
$('video').bind('ended',function(){
	$(this).parents('.video-play-box').removeClass('controls');
	$(this).removeAttr('controls');
	// exitFullscreen();
});
//閫€鍑哄叏灞�
function exitFullscreen() {
	var de = document;
	if (de.exitFullscreen) {
		de.exitFullscreen();
	} else if (de.mozCancelFullScreen) {
		de.mozCancelFullScreen();
	} else if (de.webkitCancelFullScreen) {
		de.webkitCancelFullScreen();
	}
}

winScroll.addFun('scrollAnimate',function(){
	scrollBlockAimate();
})

// 婊氬姩鍔ㄧ敾
function scrollBlockAimate(){
	var _obj = $('*[data-scroll-animate="true"]');
	var _len = _obj.length;
	_obj.each(function(i){
		var _this = $(this);
		scrollBlockAimateFun({
			o: _this,
			len: _len,
			current: i,
			callback: _this.attr('data-fun')?_this.attr('data-fun'):function(){}
		});
	});
}
function scrollBlockAimateFun(opt){
	var _opt = {}
	_opt = Object.assign(_opt,opt);
	// 褰撳墠鏍囩楂樺害
	var _o_h = _opt.o.height();
	// 褰撳墠鏍囩璺濈椤堕儴鐨勮窛绂�
	var _o_top = _opt.o.offset().top;
	// 瑙﹀彂鐐�
	var _check_point = {
		start: 0,
		start_pecent: .9,
		end: 0,
		end_pecent: .5,
	};
	if(_opt.o.attr("data-start-pecent")){
		_check_point.start_pecent = _opt.o.attr("data-start-pecent");
	}
	if(_opt.o.attr("data-end-pecent")){
		_check_point.end_pecent = _opt.o.attr("data-end-pecent");
	}
	// 瑙﹀彂鐐� start
	_check_point.start = parseFloat(_o_top - _win_h*_check_point.start_pecent);
	// 瑙﹀彂鐐� end
	_check_point.end = parseFloat(_o_top + _o_h - _win_h**_check_point.end_pecent);
	if(_scrollTop > _check_point.start && _scrollTop < _check_point.end){
		if(!_opt.o.hasClass('is-show-this')){
			_opt.o.addClass('is-show-this')
			new Function('return ' + _opt.callback)();
		}
	}else{
		//   if(_opt.o.hasClass('is-show-this')){
		//     _opt.o.removeClass('is-show-this')
		//   }
	}
}
//璁＄畻琛ㄨ揪寮忕殑鍊�
function evil(fn) {
	var Fn = Function;  //涓€涓彉閲忔寚鍚慒unction锛岄槻姝㈡湁浜涘墠绔紪璇戝伐鍏锋姤閿�
	return new Fn('return ' + fn)();
}

// 鐧惧害鍦板浘API鍔熻兘
function setMapfun(str,arr,arr2){
	var map = new BMapGL.Map(str);
	var marker_arr = [];
	var infoWindow_arr = [];
	// 鍒涘缓鑷畾涔夊浘鏍�
	if(arr2.length > 0){
		for (var _i=0,_len=arr2.length; _i<_len ; _i++) {
			var _val = arr2[_i];
			var _myIcon = false;
			if(_val.icon){
				_myIcon = new BMapGL.Icon(
					_val.icon,
					new BMapGL.Size(_val.iconSize[0],_val.iconSize[1]),
					{
						anchor:new BMapGL.Size(_val.iconSize[0]*.48,_val.iconSize[1]*.9),
						imageSize:new BMapGL.Size(_val.iconSize[0]*_val.iconSizePercent,_val.iconSize[1]*_val.iconSizePercent),
					}
				);
			}
			var _coordinate = new BMapGL.Point(_val.coordinate[0],_val.coordinate[1]);
			var _marker = new BMapGL.Marker(_coordinate,{
				icon: _myIcon
			});
			var _infoWindow = new BMapGL.InfoWindow(
				_val.address,
				{
					width: 310,
					title: _val.title
				}
			);
			map.addOverlay(_marker);
			marker_arr[_i] = _marker;
			infoWindow_arr[_i] = _infoWindow;
			openIw(_i,_coordinate,_val.showInfoWindow);
		}
	}
	// map.enableScrollWheelZoom(true);
	// map.addControl(new BMapGL.NavigationControl());
	map.addControl(new BMapGL.ScaleControl()); // 娣诲姞姣斾緥灏烘帶浠�
	map.addControl(new BMapGL.ZoomControl()); // 娣诲姞姣斾緥灏烘帶浠�
	map.centerAndZoom(new BMapGL.Point(arr[0],arr[1]), 18);
	function openIw(index,coordinate,showInfoWindow){
		marker_arr[index].addEventListener("click", function(){
			map.openInfoWindow(infoWindow_arr[index],coordinate); //寮€鍚俊鎭獥鍙�
		});
		if(showInfoWindow){
			map.openInfoWindow(infoWindow_arr[index],coordinate); //寮€鍚俊鎭獥鍙�
		}
	}
}

/**鍒囨崲閫夐」鍗�**/
/***
 * tab-t--閫夐」鍗″搴旀爣棰�
 * tab-s--閫夐」鍗″搴斿唴瀹瑰潡鍎�
 * tab-Parts--閫夐」鍗″搴旂殑鍒嗛儴
 * object--閫夐」鍗℃渶澶栧眰鏉垮潡鍎�
 * object鐨刣ata-listen--鏈眰妗嗘灦鏍囪
 * data-listen--閫夐」鍗¤Е鍙戜簨浠堕粯璁ゆ槸click,鑻ヨ鐢╤over鍦╫bject璁剧疆data-listen="hover"
 * -All鍙樉绀哄叏閮�
 * ***/
function TablesCheck(object, callback, callback_after) {
	object.each(function () {
		var _this = $(this);
		var listen = _this.attr('data-listen');
		var styleType = _this.attr('data-style-type')?_this.attr('data-style-type'):'js';
		var checkParts = _this.attr('tab-Parts');
		var points = _this.find('*[tab-t^="' + checkParts + '"]');
		var shows = _this.find('*[tab-s^="' + checkParts + '"]');
		// 澶勭悊鍑芥暟
		var activeFun = function (obj) {
			var _obj = obj;
			var tval = _obj.attr('tab-t');
			if (tval) {
				if (callback) {
					callback(_obj, _this.find('*[tab-s="' + tval + '"]'));
				}
				// 鎵€鏈夋帶鍒剁偣鍒犻櫎on
				points.removeClass('on');
				// 璁剧疆褰撳墠閫変腑椤�
				_this.attr('data-tips', tval);
				// 褰撳墠鎺у埗鐐规坊鍔爋n
				_this.find('*[tab-t="' + tval + '"]').addClass('on');
				shows.removeClass('on');
				if (tval == checkParts + '-All') {
					if(styleType == 'js'){
						shows.show();
					}
				} else {
					if(styleType == 'js'){
						shows.hide();
					}
					// 鏄剧ず瀵瑰簲鐨勬澘鍧楀苟娣诲姞on
					_this.find('*[tab-s="' + tval + '"]').addClass('on');
					if(styleType == 'js'){
						_this.find('*[tab-s="' + tval + '"]').show();
					}
				}
				if (callback_after) {
					callback_after(_obj, _this.find('*[tab-s="' + tval + '"]'));
				}
			}
		}
		if (listen == 'hover') {
			points.hover(function () {
				activeFun($(this));
			});
		} else {
			points.click(function () {
				activeFun($(this));
			});
		}
		if (points.length > 0) {
			var _d_index = false;
			points.each(function(i){
				if($(this).hasClass('on')){
					_d_index = i;
				}
			})
			activeFun(points.eq(_d_index));
		}
	});
}

// 澹版槑鍏ㄥ眬瀵硅薄锛屽悗鏈熷彲娣诲姞
function AllAreaFun() {
	var _this = this;
	this.funArray = [];
	// 娣诲姞鏂规硶
	this.addFun = function (fName, fn) {
		_this.funArray.push(fName);
		_this[fName] = fn;
	};
	// 鍒犻櫎鏂规硶
	this.removeFun = function (fName) {
		_this[fName] = null;
		delete _this[fName];
		for (var i = 0, _len = _this.funArray.length; i < _len; i++) {
			if (_this.funArray[i] == fName) {
				_this.funArray.splice(i, 1);
			}
		}
	};
	this.runFun = function () {
		var _funArray = _this.funArray;
		for (var i = 0, _len = _funArray.length; i < _len; i++) {
			_this[_funArray[i]]();
		}
	};
}

//鐢熸垚浠巑inNum鍒癿axNum鐨勯殢鏈烘暟
function randomNum(minNum, maxNum) {
	switch (arguments.length) {
		case 1:
			return parseInt(Math.random() * minNum + 1, 10);
			break;
		case 2:
			return parseInt(Math.random() * (maxNum - minNum + 1) + minNum, 10);
			break;
		default:
			return Math.random();
			break;
	}
}

/**鑾峰彇鍦板潃鏍忕殑鍙傛暟**/
function hrefGetParameter() {
	var _href = window.location.href, // 鑾峰彇鍦板潃
		_tmp, // 涓存椂
		_tmp2, // 涓存椂
		_tmp = _href.split('?'), // 鑾峰彇鍒扮殑鍙傛暟
		_rs = {}; // 杩斿洖鍊�
	if (_tmp.length > 1) {
		_tmp = _tmp[1];
		_tmp = _tmp.split('&');
		for (var i = 0; i < _tmp.length; i++) {
			_tmp2 = null;
			_tmp2 = _tmp[i].split('=');
			if (_tmp2[0] != '') {
				if (_tmp2.length > 1) {
					_rs[_tmp2[0]] = _tmp2[1];
				} else {
					_rs[_tmp2[0]] = _tmp2[0];
				}
			}
		}
	} else {
		_rs = false;
	}
	_href = _tmp = _tmp2 = null; // 閲婃斁
	return _rs;
}

// 鑾峰彇娴忚鍣ㄦ粴鍔ㄦ潯瀹藉害
function getScrollbarWidth() {
	var odiv = document.createElement('div'),//鍒涘缓涓€涓猟iv
		styles = {
			opacity: 0,
			position: 'fixed',
			left: 0,
			top: 0,
			pointerEvents: 'none',
			width: '100px',
			height: '100px',
			overflowY: 'scroll'//璁╀粬鏈夋粴鍔ㄦ潯
		}, i, scrollbarWidth;
	for (i in styles) odiv.style[i] = styles[i];
	document.body.appendChild(odiv);//鎶奷iv娣诲姞鍒癰ody涓�
	scrollbarWidth = odiv.offsetWidth - odiv.clientWidth;//鐩稿噺
	odiv.remove();//绉婚櫎鍒涘缓鐨刣iv
	return scrollbarWidth;//杩斿洖婊氬姩鏉″搴�
}


/***榧犳爣婊氬姩***/
/***
 * callback--鍥炶皟
 * ***/
function addMouseScrollFun(opt) {
	var _this = this,
		_o = {
			_if_h: opt.ifHistory ? true : false, // 鏄惁鍚姩璁板綍鍔熻兘
			_a_s_n: 0, // 婊氬姩鎬绘鏁�
			_a_u_s_n: 0, // 鍚戜笂婊氬姩鎬绘鏁�
			_a_d_s_n: 0, // 鍚戜笅婊氬姩鎬绘鏁�
			_p_dir: 0, // 涓婃婊氬姩鏂瑰悜
			_c_dir: 0, // 褰撳墠婊氬姩鏂瑰悜
			_afterScroll: opt.callback ? opt.callback : function() {}, // 婊氬姩鍚�
		};

	// 鍒濆鍖�
	_this.init = function() {
		//缁欓〉闈㈢粦瀹氭粦杞粴鍔ㄤ簨浠�
		if (document.addEventListener) {
			document.addEventListener('DOMMouseScroll', _this.scrollFunc, false);
		}
		//婊氬姩婊戣疆瑙﹀彂scrollFunc鏂规硶
		window.onmousewheel = document.onmousewheel = _this.scrollFunc;
	}

	// 婊氬姩
	_this.scrollFunc = function(e) {
		e = e || window.event;
		_o._a_s_n++; // 婊氬姩鎬绘鏁�
		_o._p_dir = _o._c_dir; // 璁板綍涓婃
		if (e.wheelDelta) { //鍒ゆ柇娴忚鍣↖E锛岃胺姝屾粦杞簨浠�
			if (e.wheelDelta > 0) { //褰撴粦杞悜涓婃粴鍔ㄦ椂
				_o._c_dir = 1;
				if (_o._if_h) {
					_o._a_u_s_n++;
				}
			}
			if (e.wheelDelta < 0) { //褰撴粦杞悜涓嬫粴鍔ㄦ椂
				_o._c_dir = -1;
				if (_o._if_h) {
					_o._a_d_s_n++;
				}
			}
		} else if (e.detail) { //Firefox婊戣疆浜嬩欢
			if (e.detail > 0) { //褰撴粦杞悜涓婃粴鍔ㄦ椂
				_o._c_dir = 1;
				if (_o._if_h) {
					_o._a_d_s_n++;
				}
			}
			if (e.detail < 0) { //褰撴粦杞悜涓嬫粴鍔ㄦ椂
				_o._c_dir = -1;
				if (_o._if_h) {
					_o._a_u_s_n++;
				}
			}
		}
		_o._afterScroll(_o._c_dir)
	}

	// 鎵ц鍒濆鍖�
	_this.init();
}

//鏁板瓧澧為暱
(function($) {
	$.fn.numberRock = function(options) {
		var defaults = {
			lastNumber: 100,
			duration: 2000,
			easing: 'swing' //swing(榛樿 : 缂撳啿 : 鎱㈠揩鎱�)  linear(鍖€閫熺殑)
		};
		var opts = $.extend({}, defaults, options);

		$(this).animate({
			num: "numberRock",
			// width : 300,
			// height : 300,
		}, {
			duration: opts.duration,
			easing: opts.easing,
			complete: function() {
				//console.log("success");
			},
			step: function(a, b) { //鍙互妫€娴嬫垜浠畾鏃跺櫒鐨勬瘡涓€娆″彉鍖�
				//console.log(a);
				// console.log(b.pos);   //杩愬姩杩囩▼涓殑姣斾緥鍊�(0~1)
				$(this).html(parseInt(b.pos * opts.lastNumber));
			}
		});
	}
})(jQuery);

//鍊掕鏃跺嚱鏁�
/**
 * @param
 * obj 澶勭悊瀵硅薄
 * times 璁剧疆鏃堕棿 榛樿60
 * endStatue 鍊掕鏃跺畬涔嬪悗鏄惁鍥炲埌鍘熸潵鐘舵€�0:鍚� 1:鏄�
 * callback 璁℃椂瀹屾垚鍥炶皟鍑芥暟
 */
function jsInnerTimeout(opt) {
	var _this = this;
	var opts = {
		obj: opt.obj ? opt.obj : document.getElementById('getCode'),
		times: opt.times ? opt.times : 60,
		endStatue: opt.endStatue ? opt.endStatue : 0,
		callfun: function(e) {
			if (opt.callback) {
				opt.callback(e);
			}
		}
	}
	opts.obj.setAttribute('data-word', opts.obj.innerText);
	_this.goSet = function() {
		if (opts.times < 0) {
			if(opts.endStatue == 1){
				opts.obj.removeAttribute("disabled");
				opts.obj.innerText = opts.obj.getAttribute('data-word');
			}
			opts.callfun(_this);
			return false;
		} else {
			opts.obj.setAttribute("disabled", "disabled");
			opts.obj.innerText = opts.times;
			setTimeout(function() {
				_this.goSet();
			}, 1000);
		}
		opts.times--;
	}
	_this.goSet();
};

/**缁熶竴楂樺害**/
/***
 * opints--浼犲叆瀵硅薄
 * opints.obj--闇€瑕佸鐞嗗垪琛ㄥ璞�
 * opints.nums--鏄惁鍒嗙粍涓嶅垎缁勫垯涓嶅～鍐�
 * ***/
function ListSameHeight(opints) {
	var obj = opints.obj;
	var num = opints.nums ? opints.nums : false;
	obj.height('auto');
	if (num == false || num >= obj.length) {
		var li_h = 0;
		obj.each(function(i) {
			$(this).height('auto');
			if (li_h < this.offsetHeight) {
				li_h = this.offsetHeight;
			}
		});
		obj.height(li_h);
	} else {
		var li_h = 0;
		obj.each(function(i) {
			if (i % num == num - 1) {
				$(this).height('auto');
				if (li_h < this.offsetHeight) {
					li_h = this.offsetHeight;
				}
				for (var ii = num - 1; ii >= 0; ii--) {
					obj.eq(i - ii).height(li_h);
				}
				li_h = 0;
			} else {
				$(this).height('auto');
				if (li_h < this.offsetHeight) {
					li_h = this.offsetHeight;
				}
				if (i == obj.length - 1) {
					for (var ii = obj.length % num - 1; ii >= 0; ii--) {
						obj.eq(i - ii).height(li_h);
					}
				}
			}
		});
	}
}
/**鍥剧墖鏀惧ぇ**/
function Zoom(imgbox, hoverbox, l, t, x, y, h_w, h_h, showbox) {
	var moveX = x - l - (h_w / 2);
	//榧犳爣鍖哄煙璺濈
	var moveY = y - t - (h_h / 2);
	//榧犳爣鍖哄煙璺濈
	if (moveX < 0) {
		moveX = 0
	}
	if (moveY < 0) {
		moveY = 0
	}
	if (moveX > imgbox.width() - h_w) {
		moveX = imgbox.width() - h_w
	}
	if (moveY > imgbox.height() - h_h) {
		moveY = imgbox.height() - h_h
	}
	//鍒ゆ柇榧犳爣浣垮叾涓嶈窇鍑哄浘鐗囨
	var zoomX = showbox.width() / imgbox.width()
	//姹傚浘鐗囨瘮渚�
	var zoomY = showbox.height() / imgbox.height()
	showbox.css({
		left: -(moveX * zoomX),
		top: -(moveY * zoomY)
	})
	hoverbox.css({
		left: moveX,
		top: moveY
	})
	//纭畾浣嶇疆
}
function Zoomhover(imgbox, hoverbox, showbox) {
	var l = imgbox.offset().left;
	var t = imgbox.offset().top;
	var w = hoverbox.width();
	var h = hoverbox.height();
	var time;
	imgbox = imgbox.find('.probox');
	imgbox.mouseover(function(e) {
		l = imgbox.offset().left;
		t = imgbox.offset().top;
		w = hoverbox.width();
		h = hoverbox.height();
		var n_src = $(this).find('img').attr('src');
		var o_src = showbox.attr('src');
		if (n_src != o_src) {
			showbox.attr('src', n_src);
		}
		var x = e.pageX;
		var y = e.pageY;
		var obj = $(this);
		$(".hoverbox,.showbox").show();
		hoverbox.css("opacity", "0.3")
		time = setTimeout(function() {
			Zoom(obj, hoverbox, l, t, x, y, w, h, showbox)
		}, 1)
	}).mousemove(function(e) {
		l = imgbox.offset().left;
		t = imgbox.offset().top;
		w = hoverbox.width();
		h = hoverbox.height();
		var x = e.pageX;
		var y = e.pageY;
		var obj = $(this);
		time = setTimeout(function() {
			Zoom(obj, hoverbox, l, t, x, y, w, h, showbox)
		}, 1)
	}).mouseout(function() {
		showbox.parent().hide()
		hoverbox.hide();
	})
}

/**鎵嬫満鍙风爜妫€娴�**/
function isPoneAvailable(num) {
	var myreg=/^[1][3,4,5,7,8][0-9]{9}$/;
	if (!myreg.test(num)) {
		return false;
	} else {
		return true;
	}
}

//璁＄畻琛ㄨ揪寮忕殑鍊� 鏇夸唬eval
function evil(fn) {
	var Fn = Function;  //涓€涓彉閲忔寚鍚慒unction锛岄槻姝㈡湁浜涘墠绔紪璇戝伐鍏锋姤閿�
	return new Fn('return ' + fn)();
}

//鑾峰彇cookie锛屽弬鏁皀ame鎸囧畾瑕佽幏鍙栫殑cookie鐨勫悕绉�
function getCookie(name) {
	var start = document.cookie.indexOf(name + "="); //寰楀埌cookie瀛楃涓蹭腑鐨勫悕绉�
	var len = start + name.length + 1; //寰楀埌浠庤捣濮嬩綅缃埌缁撴潫cookie浣嶇疆鐨勯暱搴�
	//濡傛灉璧峰娌℃湁鍊间笖name涓嶅瓨鍦ㄤ簬cookie瀛楃涓蹭腑锛屽垯杩斿洖null
	if ((!start) && (name != document.cookie.substring(0, name.length))) {
		return null;
	}
	if (start == -1) return null; //濡傛灉璧峰浣嶇疆涓�-1涔熶负null
	var end = document.cookie.indexOf(';', len); //鑾峰彇cookie灏鹃儴浣嶇疆
	if (end == -1) end = document.cookie.length; //璁＄畻cookie灏鹃儴闀垮害
	return decodeURI(document.cookie.substring(len, end)); //鑾峰彇cookie鍊�
}
//璁剧疆cookie锛宯ame涓哄悕绉帮紝value涓哄€硷紝expires涓鸿繃鏈熸棩锛宲ath涓鸿矾寰勶紝domain涓哄煙鍚嶏紝secure涓哄姞瀵�
function setCookie(name, value, expires, path, domain, secure) {
	var today = new Date();
	today.setTime(today.getTime());
	if (expires) {
		expires = expires * 1000 * 60 * 60 * 24; //璁＄畻cookie鐨勮繃鏈熸绉掓暟
	}
	//璁＄畻cookie鐨勮繃鏈熸棩鏈�
	var expires_date = new Date(today.getTime() + (expires));
	//鏋勯€犲苟淇濆瓨cookie瀛楃涓�
	document.cookie = name + '=' + encodeURI(value) +
		((expires) ? ';expires=' + expires_date.toGMTString() : '') + //expires.toGMTString()
		((path) ? ';path=' + path : '') +
		((domain) ? ';domain=' + domain : '') +
		((secure) ? ';secure' : '');
}

// 閫氳繃url杩涜涓嬭浇
function downloadUrlFile (url, fileName) {
	const a = document.createElement('a')
	document.body.appendChild(a)
	a.style = 'display: none'
	a.href = url
	a.download = fileName
	a.click()
	window.URL.revokeObjectURL(url)
}